package org.example.strategy;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.LinkedList;

public class SaveFileStrategy implements EditorStrategy {

    private String filePath;
    private LinkedList<String> fileContent;
    public SaveFileStrategy(String filePath,LinkedList<String> fileContent) {
        this.filePath = filePath;
        this.fileContent = fileContent;
    }

    @Override
    public void performAction() {
        try(BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(filePath))) {
            for (String line:fileContent){
                bufferedWriter.write(line);
                bufferedWriter.newLine();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
